<?
	if(isset($_GET['act'])){
		if($_GET['act'] == "logout"){
			session_destroy();
			header("Location: ".$root."/trang-chu/");
		}
	}
	
	if(isset($_SESSION['url'])){
		$url = $_SESSION['url'];
	}
	else{
		$url="trang-chu";
	}
	if($_SESSION['is_login'] == true){
		header("Location: ".$root."/trang-chu/");
	}
	
	if(isset($_POST['action'])){
		$txtUsername = addslashes($_POST['txtUsername']);
		$txtPassword = md5(addslashes($_POST['txtPassword']));
		$chkRememberLogin = $_POST['chkRememberLogin'];
		
		$rs = $db->query("SELECT * FROM ".$prefix."nguoidung WHERE u_name = '$txtUsername' AND u_pass = '$txtPassword' AND u_banned = 1");
		$msg = "";
		if($db->num_rows($rs) != 0){
			$row = $db->fetch_array($rs);
			$_SESSION['utenshop'] = $row[u_tenshop];
			$_SESSION['uname'] = $row[u_name];
			$_SESSION['uid'] = $row[u_id];
			$_SESSION['is_login'] = true;
			
			if($chkRememberLogin == 1){
				setcookie('uname',$row[u_name]);
				setcookie('uid',$row[u_id]);
				setcookie('is_login',true);
			}
			header("Location: ".$root."/trang-chu/");
		}else{
			$msg = "Thông tin đăng nhập sai !";
		}
	}
?>
<div id="linkPath">
 <div class="linkPath">
    <div class="linkPath-text">    
        <div><a href="<?=$root?>/trang-chu/">Trang chủ</a></div><div><a>Đăng nhập</a></div>
    </div>
</div>
    </div>
    <!-- Main Page-Content { -->
<form action="" name="frmLogin" id="frmLogin" method="post" onsubmit="return checkLogin();">	
<div id="login-content">                    
	<div id="userLogin">
            <div class="ads" style="padding-left:0px;">
                <img src="<?=$root?>/img/login.png" alt="" />                
            </div>            
            <div class="userLogin">     
                    <p class="form-header">Đăng nhập</p>
                    <div class="field-content">
                        <div class="field">
			                <span class="col-l">Tên đăng nhập</span>
			                <span class="col-r"><input id="txtUsername" name="txtUsername" type="text" value="" /><span>
		                </div>
		                <div class="field">
			                <span class="col-l">Mật khẩu</span>
			                <span class="col-r"><input id="txtPassword" name="txtPassword" type="password" /></span>
		                </div>
					<?
						if($msg != "" || $msg != NULL){
					?>
		                <div class="fieldErrorGroup">
		                    <span class="col-l">&nbsp;</span>
			                <div id="ctl00_idMainHolder_idUserLogin_error" class="errorGroup"><?=$msg?></div>
		                </div>
					<? }?>
		                <div class="field">
			                <span class="col-l">&nbsp;</span>
			                <span class="col-r">
								<input id="chkRememberLogin" name="chkRememberLogin" value="1" class="checkbox" type="checkbox" />
								Ghi nhớ tài khoản.
							</span>
		                </div>
		                <div class="field">
		                    <span class="col-l">&nbsp;</span>
							<span class="col-r"><input type="hidden" name="action" id="action" value="action" /></span>
			                <span class="col-r">
								<input id="accept" class="btnLogin" name="accept" type="submit" value="Đăng nhập"/>
							</span>
		                </div>
		                <div class="field">
			                <span class="col-l">&nbsp;</span>
			                <a href="?mod=quenmatkhau" title="Quên mật khẩu">Quên mật khẩu</a> | 
			                <a href="?mode=dangki" title="Đăng ký mới">Đăng ký mới</a>
		                </div>	
		                <div class="field">
		                    <p style="font-size:8pt;color:Gray;margin-left:20px;margin-right:10px">(*) Vui lòng điền đúng tên đăng nhập và mật khẩu </p>
		                </div>            		            
                    </div>
            </div>
	</div>
</div>
    <div style="clear:both;"></div>
    <!-- } Main Page-Content -->
</form>
                 <div id='zEventZone' style="margin:0px auto;text-align:center;padding-bottom:10px;"></div>
</div>